/****** Object:  Stored Procedure [dbo].spLuuKhoGetList Script Date: 8/6/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[spLuuKhoGetList]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spLuuKhoGetList]
GO

/******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**		07/08/2012	SongTM					Innit created
*******************************************************************************/

CREATE PROCEDURE [dbo].[spLuuKhoGetList]
(
	@MaKho nvarchar(6),
	@MaThuoc nvarchar(12),
	@SoLo nvarchar(12),
	@Min int
)
WITH ENCRYPTION
AS

SELECT
	[tbl_LuuKho].*,
	tbl_KhoHang.TenKho
FROM
	[tbl_LuuKho] INNER JOIN tbl_KhoHang ON tbl_KhoHang.MaKho = tbl_LuuKho.MaKho
WHERE
	((@MaKho is NUll) OR @MaKho = [tbl_LuuKho].MaKho)
	AND ((@MaThuoc is NUll) OR @MaThuoc = MaThuoc)
	AND ((@SoLo is NUll) OR @SoLo = SoLo)
	AND ((@Min is NUll) OR @Min < TonKho)
ORDER BY [tbl_LuuKho].HanSuDung asc
GO

--GRANT EXECUTE ON [dbo].[spLuuKhoGetList] TO [sa]
--GO
